package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;

public class RulesStandartFrame extends JFrame
{
	/* Current shown window */	
	public static RulesStandartFrame currentRulesStandartFrame = null;

	/* C'tor */
	private RulesStandartFrame()
	{	
		super("Rules");
		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setSize(new Dimension(800,550));
		setLayout(new BorderLayout());
		
		addStandartButtons();
		addRulesTables();
		
		currentRulesStandartFrame = this;
	}

	public static RulesStandartFrame getInctance()
	{
		if(currentRulesStandartFrame == null)
		{
			return new RulesStandartFrame();
		}
		
		return currentRulesStandartFrame;
	}
	
	private void addRulesTables()
	{
		// TODO Auto-generated method stub
		
	}

	private void addStandartButtons()
	{
		Box tableBox = Box.createHorizontalBox();
		
		JButton finish = new JButton("Finish");
		finish.setToolTipText("Close and save changes");
		JButton cancel = new JButton("Cancel");
		cancel.setToolTipText("Close without saving changes");
		JButton help = new JButton("Help");
		cancel.setToolTipText("Help for rules screen");
		
		tableBox.add(help);		
		tableBox.add(finish);
		tableBox.add(cancel);
	    
		
		/*Help button listener - closes the frame*/		
		help.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) 
			{
				//TODO: call Maya function		
			}	  
		});	
		
		finish.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) 
			{
				currentRulesStandartFrame.dispose();				
			}	  
		});
		  
		cancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) 
			{
				currentRulesStandartFrame.dispose();			
			}	  
		});

	    add(tableBox, BorderLayout.SOUTH);
		
	}

}
